import Vue from 'vue'
import VueRouter from 'vue-router'
import EmptyLayout from '@/layouts/EmptyLayout'
Vue.use(VueRouter)
const routes = [
  {
    path:'/',
    component:()=> import('../views/index.vue'),
    children:[
      {
        path:'',
        component: () => import('../components/index/index')
      },
      {
        path: 'login',
        component: () => import("@/views/Login.vue")
      },
      {
        path: 'problem/search',
        component: () => import("../components/search/index")
      },
      {
        path: 'register',
        component: () => import("@/views/Register.vue")
      },
    ]
  },

  {
    path: '/home',
    component: () => import('../components/home/index'),
    meta: {
      title: '首页',
    },
    children: [
      {
        path: 'user',
        component: () => import('../components/home/user/index'),
        meta: {
          title: '用户管理',
        },
      },
      {
        path: 'problem',
        component: EmptyLayout,
        meta: {
          title: '题目管理',
        },
        children: [
          {
            path: 'add',
            component: () => import('../components/home/problem/Add'),
            meta: {
              title: '添加题目',
            }
          }
        ]
      },
      {
        path: 'myExam',
        component: () => import('../components/home/myExam/index'),
        meta: {
          title: '我的考试',
        },
      },
      {
        path: 'exam',
        component: EmptyLayout,
        meta: {
          title: '考试管理',
        },
        children: [
          {
            path: 'add',
            component: () => import('../components/home/exam/Add'),
            meta: {
              title: '创建考试',
            }
          },
          {
            path: 'list',
            component: () => import('../components/home/exam/List'),
            meta: {
              title: '考试列表',
            }
          },
        ]
      }
    ]
  },
  {
    path:'/exam',
    component:()=> import('../components/exam/index.vue')
  },
  {
    path:'/problem/add',
    redirect: '/home/problem/add'
  },
]

const router = new VueRouter({
  routes
})

export default router
